#include "hdform.h"
#include "ui_hdform.h"
#include <QKeyEvent>
#include <QSerialPort>
#include <QDebug>
#include "uart.h"
hdForm::hdForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::hdForm)
{
    ui->setupUi(this);
    this->setStyleSheet("background-color: rgb(0, 186, 238);");
    box_sel=NULL;
    QImage *img=GetLogo();
    if(img!=NULL)
        ui->label_Logo->setPixmap(QPixmap::fromImage(*img).scaled(ui->label_Logo->size()));

}

hdForm::~hdForm()
{
    delete ui;
}
void hdForm::keyPressEvent(QKeyEvent *event)
{
    int key=event->key();
    qDebug()<< key;
//    printf("key= %d\n",key);
    if(key==Qt::Key_F12||key==Qt::Key_Exit)
    {
        if(ShowPreWin())
            this->hide();
    }
    else
        if(ShowWin(key,0))
            this->hide();


}

void hdForm::on_checkBox_clicked()
{
    sendUartCmd_timing(hd_720p_60);
    SelBox(ui->checkBox);
}

void hdForm::on_checkBox_2_clicked()
{
    sendUartCmd_timing(hd_720p_5994);
    SelBox(ui->checkBox_2);
}

void hdForm::on_checkBox_3_clicked()
{
    sendUartCmd_timing(hd_720p_50);
    SelBox(ui->checkBox_3);
}

void hdForm::on_checkBox_6_clicked()
{
    sendUartCmd_timing(hd_1080i_60);
    SelBox(ui->checkBox_6);
}

void hdForm::on_checkBox_5_clicked()
{
    sendUartCmd_timing(hd_1080i_5994);
    SelBox(ui->checkBox_5);
}

void hdForm::on_checkBox_4_clicked()
{
    sendUartCmd_timing(hd_1080i_50);
    SelBox(ui->checkBox_4);
}

void hdForm::on_checkBox_9_clicked()
{
    sendUartCmd_timing(hd_1080p_60);
    SelBox(ui->checkBox_9);
}

void hdForm::on_checkBox_8_clicked()
{
    sendUartCmd_timing(hd_1080p_5994);
    SelBox(ui->checkBox_8);
}

void hdForm::on_checkBox_7_clicked()
{
    sendUartCmd_timing(hd_1080p_50);
    SelBox(ui->checkBox_7);
}

void hdForm::on_checkBox_11_clicked()
{
    sendUartCmd_timing(hd_1080p_30);
    SelBox(ui->checkBox_11);
}

void hdForm::on_checkBox_10_clicked()
{
    sendUartCmd_timing(hd_1080p_2997);
    SelBox(ui->checkBox_10);
}

void hdForm::on_checkBox_12_clicked()
{
    sendUartCmd_timing(hd_1080p_25);
    SelBox(ui->checkBox_12);
}

void hdForm::on_checkBox_13_clicked()
{
    sendUartCmd_timing(hd_1080p_24);
    SelBox(ui->checkBox_13);
}

void hdForm::on_checkBox_14_clicked()
{
    sendUartCmd_timing(hd_1080p_23976);
    SelBox(ui->checkBox_14);
}

void hdForm::on_checkBox_17_clicked()
{
    SelBox(ui->checkBox_17);
    sendUartCmd_timing(hd_1080p_120);
}

void hdForm::on_checkBox_15_clicked()
{
    SelBox(ui->checkBox_15);
    sendUartCmd_timing(hd_1080p_119);
}

void hdForm::on_checkBox_16_clicked()
{
    SelBox(ui->checkBox_16);
    sendUartCmd_timing(hd_1080p_100);
}
